package com.airena.context;

public class BaseContext {

    public static final ThreadLocal<Long> threadLocal = new ThreadLocal<>();
    private static final ThreadLocal<Long> roleThreadLocal = new ThreadLocal<>();

    // 用户 ID 操作
    public static void setCurrentId(Long id) {
        threadLocal.set(id);
    }

    public static Long getCurrentId() {
        return threadLocal.get();
    }

    public static void removeCurrentId() {
        threadLocal.remove();
    }


    // 角色 ID 操作
    public static void setCurrentRoleId(Long id) {
        roleThreadLocal.set(id);
    }

    public static Long getCurrentRoleId() {
        return roleThreadLocal.get();
    }

    public static void removeCurrentRoleId() {
        roleThreadLocal.remove();
    }

    // 清理
    public static void clear() {
        threadLocal.remove();
        roleThreadLocal.remove();
    }

}
